local remove_player = fk.CreateSkill{
  name = "#remove_player",
}

Fk:loadTranslationTable{
  ["#remove_player"] = "移出游戏",
}

---@param player Player
local checkRemove = function (player)
  local markName = "@@remove_player"
  for mark, _ in pairs(player.mark) do
    if mark == markName or mark == markName .. "_list" then return true end
    if mark:startsWith(markName .. "-") then
      for _, suffix in ipairs(MarkEnum.TempMarkSuffix) do
        if mark:find(suffix, 1, true) then return true end
      end
    end
  end
end

remove_player:addEffect("prohibit", {
  prohibit_use = function (self, player, card)
    return card and checkRemove(player)
  end,
  is_prohibited = function(self, from, player, card)
    return card and checkRemove(player)
  end,
})

remove_player:addEffect(fk.PreHpRecover, {
  can_refresh = function(self, event, target, player, data)
    return target == player and checkRemove(player)
  end,
  on_refresh = function(self, event, target, player, data)
    data.num = 0
    data.prevented = true
  end,
})

remove_player:addEffect(fk.PreHpLost, {
  can_refresh = function(self, event, target, player, data)
    return target == player and checkRemove(player)
  end,
  on_refresh = function(self, event, target, player, data)
    data.num = 0
    data.prevented = true
  end,
})

remove_player:addEffect(fk.DamageInflicted, {
  can_refresh = function(self, event, target, player, data)
    return target == player and checkRemove(player)
  end,
  on_refresh = function(self, event, target, player, data)
    data:preventDamage()
  end,
})

return remove_player